import { Heap } from "./heap";
import { reverseCompare, defaultCompare, type ICompareFunc } from "./compare";

export class MaxHeap<T> extends Heap<T> {
  protected compareFn: ICompareFunc<T>;
  constructor(compareFn = defaultCompare<T>) {
    super();
    this.compareFn = reverseCompare(compareFn);
  }

  findMaximum() {
    return this.isEmpty ? void 0 : this.heap[0];
  }
}
